/***************************************************************************
 *   Copyright (C) 2009 by Marian Skvarek   *
 *   skvarek.marian@gmail.com   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#include "CResources.h"

#include <QIcon>

namespace easyscore
{
	namespace globals
	{
		CResources *CResources::mInstance = 0;

		CResources::CResources()
		{
			initialize();
		}
		
		void CResources::initialize()
		{
			int w = CGlobals::getUnitSymbolWidth();
			
			mNotePixmaps.insert(NOTE_VALUE_LONGA, new QPixmap(QPixmap(":/res/img/symbols/note128.png").scaledToWidth(w,Qt::SmoothTransformation)));
			mNotePixmaps.insert(NOTE_VALUE_DOUBLE_WHOLE, new QPixmap(QPixmap(":/res/img/symbols/note128.png").scaledToWidth(w,Qt::SmoothTransformation)));
                        mNotePixmaps.insert(NOTE_VALUE_WHOLE, ( new QPixmap( QPixmap(":/res/img/symbols/note128.png").scaledToWidth(w*2,Qt::SmoothTransformation))));
			mNotePixmaps.insert(NOTE_VALUE_HALF, ( new QPixmap( QPixmap(":/res/img/symbols/note64.png").scaledToWidth(w,Qt::SmoothTransformation))));
			mNotePixmaps.insert(NOTE_VALUE_QUARTER, new QPixmap(QPixmap(":/res/img/symbols/note32.png").scaledToWidth(w,Qt::SmoothTransformation)));
			mNotePixmaps.insert(NOTE_VALUE_EIGHTH, new QPixmap(QPixmap(":/res/img/symbols/note32.png").scaledToWidth(w,Qt::SmoothTransformation)));
			mNotePixmaps.insert(NOTE_VALUE_SIXTEENTH, new QPixmap(QPixmap(":/res/img/symbols/note32.png").scaledToWidth(w,Qt::SmoothTransformation)));
			mNotePixmaps.insert(NOTE_VALUE_THIRTYSECOND, new QPixmap(QPixmap(":/res/img/symbols/note32.png").scaledToWidth(w,Qt::SmoothTransformation)));
			mNotePixmaps.insert(NOTE_VALUE_SIXTYFOURTH, new QPixmap(QPixmap(":/res/img/symbols/note32.png").scaledToWidth(w,Qt::SmoothTransformation)));
			mNotePixmaps.insert(NOTE_VALUE_HUNDREDTWENTYEIGTH, new QPixmap(QPixmap(":/res/img/symbols/note32.png").scaledToWidth(w,Qt::SmoothTransformation)));
			
                        mActiveNotePixmaps.insert(NOTE_VALUE_LONGA, new QPixmap(QPixmap(":/res/img/symbols/noteActive128.png").scaledToWidth(w,Qt::SmoothTransformation)));
                        mActiveNotePixmaps.insert(NOTE_VALUE_DOUBLE_WHOLE, new QPixmap(QPixmap(":/res/img/symbols/noteActive128.png").scaledToWidth(w,Qt::SmoothTransformation)));
                        mActiveNotePixmaps.insert(NOTE_VALUE_WHOLE, ( new QPixmap( QPixmap(":/res/img/symbols/noteActive128.png").scaledToWidth(w*2,Qt::SmoothTransformation))));
                        mActiveNotePixmaps.insert(NOTE_VALUE_HALF, ( new QPixmap( QPixmap(":/res/img/symbols/noteActive64.png").scaledToWidth(w,Qt::SmoothTransformation))));
                        mActiveNotePixmaps.insert(NOTE_VALUE_QUARTER, new QPixmap(QPixmap(":/res/img/symbols/noteActive32.png").scaledToWidth(w,Qt::SmoothTransformation)));
                        mActiveNotePixmaps.insert(NOTE_VALUE_EIGHTH, new QPixmap(QPixmap(":/res/img/symbols/noteActive32.png").scaledToWidth(w,Qt::SmoothTransformation)));
                        mActiveNotePixmaps.insert(NOTE_VALUE_SIXTEENTH, new QPixmap(QPixmap(":/res/img/symbols/noteActive32.png").scaledToWidth(w,Qt::SmoothTransformation)));
                        mActiveNotePixmaps.insert(NOTE_VALUE_THIRTYSECOND, new QPixmap(QPixmap(":/res/img/symbols/noteActive32.png").scaledToWidth(w,Qt::SmoothTransformation)));
                        mActiveNotePixmaps.insert(NOTE_VALUE_SIXTYFOURTH, new QPixmap(QPixmap(":/res/img/symbols/noteActive32.png").scaledToWidth(w,Qt::SmoothTransformation)));
                        mActiveNotePixmaps.insert(NOTE_VALUE_HUNDREDTWENTYEIGTH, new QPixmap(QPixmap(":/res/img/symbols/noteActive32.png").scaledToWidth(w,Qt::SmoothTransformation)));

                        w *=2;
			mPausePixmaps.insert(NOTE_VALUE_LONGA, new QPixmap(QPixmap(":/res/img/symbols/rest32.png").scaledToWidth(w,Qt::SmoothTransformation)));
			mPausePixmaps.insert(NOTE_VALUE_DOUBLE_WHOLE, new QPixmap(QPixmap(":/res/img/symbols/rest32.png").scaledToWidth(w,Qt::SmoothTransformation)));
                        mPausePixmaps.insert(NOTE_VALUE_WHOLE, ( new QPixmap( QPixmap(":/res/img/symbols/rest128.png").scaledToWidth(w,Qt::SmoothTransformation))));
                        mPausePixmaps.insert(NOTE_VALUE_HALF, ( new QPixmap( QPixmap(":/res/img/symbols/rest64.png").scaledToWidth(w,Qt::SmoothTransformation))));
			mPausePixmaps.insert(NOTE_VALUE_QUARTER, new QPixmap(QPixmap(":/res/img/symbols/rest32.png").scaledToWidth(w,Qt::SmoothTransformation)));
			mPausePixmaps.insert(NOTE_VALUE_EIGHTH, new QPixmap(QPixmap(":/res/img/symbols/rest16.png").scaledToWidth(w,Qt::SmoothTransformation)));
			mPausePixmaps.insert(NOTE_VALUE_SIXTEENTH, new QPixmap(QPixmap(":/res/img/symbols/rest8.png").scaledToWidth(w,Qt::SmoothTransformation)));
			mPausePixmaps.insert(NOTE_VALUE_THIRTYSECOND, new QPixmap(QPixmap(":/res/img/symbols/rest4.png").scaledToWidth(w,Qt::SmoothTransformation)));
			mPausePixmaps.insert(NOTE_VALUE_SIXTYFOURTH, new QPixmap(QPixmap(":/res/img/symbols/rest2.png").scaledToWidth(w,Qt::SmoothTransformation)));
			mPausePixmaps.insert(NOTE_VALUE_HUNDREDTWENTYEIGTH, new QPixmap(QPixmap(":/res/img/symbols/rest1.png").scaledToWidth(w,Qt::SmoothTransformation)));
                        w /=2;
			
                        mAccidentalPixmaps.insert(eAccidentalSharp,new QPixmap(QPixmap(":/res/img/symbols/sharp.png").scaledToWidth(w,Qt::SmoothTransformation)));
                        mAccidentalPixmaps.insert(eAccidentalFlat,new QPixmap(QPixmap(":/res/img/symbols/flat.png").scaledToWidth(w,Qt::SmoothTransformation)));
                        mAccidentalPixmaps.insert(eAccidentalNatural,new QPixmap(QPixmap(":/res/img/symbols/neutral.png").scaledToWidth(w,Qt::SmoothTransformation)));

                        mRightFlagPixmap = QPixmap(":/res/img/symbols/rightFlag.png").scaledToWidth(w,Qt::SmoothTransformation);
                        mLeftFlagPixmap = QPixmap(":/res/img/symbols/leftFlag.png").scaledToWidth(w,Qt::SmoothTransformation);

			w *= 3;
			mClefPixmaps.insert(eClefTreble,new QPixmap(QPixmap(":/res/img/symbols/gClef.png").scaledToWidth(w,Qt::SmoothTransformation)));		
			mClefPixmaps.insert(eClefBass,new QPixmap(QPixmap(":/res/img/symbols/fClef.png").scaledToWidth(w,Qt::SmoothTransformation)));
                        mClefPixmaps.insert(eClefNeutral,new QPixmap(QPixmap(":/res/img/symbols/neutralClef.png").scaledToWidth(w,Qt::SmoothTransformation)));

                        mSharpIcon = QIcon(QPixmap(":/res/img/symbols/sharp.png"));

                        mGhostNotePixmap = QPixmap(":/res/img/symbols/ghostNote.png");
                        mActiveGhostNotePixmap = QPixmap(":/res/img/symbols/ghostNoteActive.png");

		}


		CResources::~CResources()
		{
			
		}
		
//Public methods
		QPixmap &CResources::getNotePixmap ( NOTE_VALUE value )
		{
			return *(mNotePixmaps.value(value));
		}

                QPixmap &CResources::getActiveNotePixmap ( NOTE_VALUE value )
                {
                    return *(mActiveNotePixmaps.value(value));
                }
		
		QPixmap &CResources::getPausePixmap ( NOTE_VALUE value )
		{
			return *(mPausePixmaps.value(value));
		}
		
		QPixmap &CResources::getClefPixmap ( EClef clef )
		{
			return *(mClefPixmaps.value(clef));
		}

                QPixmap &CResources::getAccidentalPixmap(EAccidental accidental)
                {
                    return *(mAccidentalPixmaps.value(accidental));
                }



	}//namespace globals
}//namespace easyscore
